﻿/* *****************************************************************************
 * @ Encoding: UTF-8
 * @ File Name: naughty_differential_node_cos.cpp
 * @ Author: carl
 * @ Email: naughtygeng@qq.com
 * @ Created Time: 2022-7月-09(星期六) 19:15:10
 * @ All Rights Reserved
 * *****************************************************************************/

#include "naughty_differential_node_cos.hpp"
#include "naughty_differential_node_sin.hpp"
#include "naughty_differential_node_mul.hpp"
#include "naughty_differential_node_num.hpp"

namespace naughty_differential
{

node_cos::node_cos(std::shared_ptr<node_base> param_ptr)
    :
        node_base({param_ptr})
{

}

node_cos::node_cos(std::vector<std::shared_ptr<node_base>> params)
    :
        node_base(params)
{

}

std::shared_ptr<node_base> node_cos::differential(std::string variable)
{
    return std::make_shared<node_mul>(std::make_shared<node_mul>(std::make_shared<node_num>(-1), std::make_shared<node_sin>(get_parameters()[0])), get_parameters()[0]->differential(variable));
}

enum node_type node_cos::get_node_type()
{
    return node_type_cos;
}

std::string node_cos::serialize()
{
    return {};
}

std::string node_cos::to_string() const
{
    return std::string("cos(") + get_parameters()[0]->to_string() + ")";
}

std::shared_ptr<node_base> node_cos::clone()
{
    return std::make_shared<node_cos>(parameters_clone());
}

double node_cos::get_value(std::map<std::string, double> val_value_map)
{
    std::vector<double> params_value = get_params_value(val_value_map);

    return std::cos(params_value[0]);
}

std::string node_cos::identity_string() const
{
    return std::string("cos(") + get_parameters()[0]->to_string() + ")";
}

}
